import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class Config {

	private String server;
	private int port;

	public void load() throws FileNotFoundException, IOException {
		Properties prop = new Properties();
		File file = new File("config.properties");
		if (file.exists())
			prop.load(new FileInputStream(file));

		server = prop.getProperty("server", "");
		port = Integer.parseInt(prop.getProperty("port", "1399"));
	}

	public String getServer() {
		return server;
	}

	public int getPort() {
		return port;
	}

	public void setServer(String server) {
		this.server = server;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public void save() throws FileNotFoundException {
		Properties prop = new Properties();

		prop.setProperty("server", server);
		prop.setProperty("server", port + "");
		port = Integer.parseInt(prop.getProperty("port", "1399"));
		prop.save(new FileOutputStream("config.properties"), "");
	}

}
